package com.cctc.mychat.server.handler.Message;

import com.cctc.mychat.common.protocol.message.impl.request.HeartBeatRequestMessage;
import com.cctc.mychat.common.protocol.message.impl.response.HeartBeatResponseMessage;
import com.cctc.mychat.common.util.JsonUtils;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

public class HeartBeatRequestMessageHandler extends SimpleChannelInboundHandler<HeartBeatRequestMessage> {
    @Override
    protected void channelRead0(ChannelHandlerContext ctx, HeartBeatRequestMessage request) throws Exception {
        System.out.println("[HeartBeatRequestMessageHandler] 心跳消息：" + JsonUtils.toJson(request));

        HeartBeatResponseMessage response = HeartBeatResponseMessage.builder().build();
        System.out.println("[HeartBeatRequestMessageHandler] 心跳检测成功！！！");
        ctx.writeAndFlush(response);
    }
}
